import java.util.HashMap;

public class Solution {
    public int GetUglyNumber_Solution(int index) {
        if(index<=6){
            return index;
        }
        //丑数的形式2^x3^y5^z
        int x=0, y=0,z=0;
        int [] arr=new int [index];
        arr[0]=1;
        for(int i=1;i<index;i++){
            int val=Math.min(arr[x]*2,Math.min(arr[y]*3,arr[z]*5));
            arr[i]=val;
            if(val==arr[x]*2){
                x++;
            }
            if(val==arr[y]*3){
                y++;
            }
            if(val==arr[z]*5){
                z++;
            }
        }
        return arr[index-1];
    }

        // 哈希桶加双指针
    public int lengthOfLongestSubstring1 (String s) {

        HashMap<Character,Integer> map=new HashMap<>();
        int i=-1;
        int res=0;
        for(int j=0;j<s.length();j++){
            if(map.containsKey(s.charAt(j))){
                i=Math.max(i,map.get(s.charAt(j)));
                map.put(s.charAt(j),j);
            }else{
                map.put(s.charAt(j),j);
            }
            res=Math.max(res,j-i);
        }
        return res;
    }
}